#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;

string input[12];

// 非独立替换
void change(string &s, string old_val, string new_val)
{
    int pos = 0;
    while ((pos = s.find(old_val, pos)) != s.npos)
    {
        s.erase(pos, old_val.length());
        s.insert(pos, new_val);
        pos++;
    }
}

// 独立替换
void independ_change(string &s, string old_val, string new_val)
{
    // 前后加空格是因为chatAI里统一每个单词前后都加了空格
    if (s == (' ' + old_val + ' '))
    {
        // 只输入了一个要改变的val 如"      me  "
        s = (' ' + new_val + ' ');
        return;
    }

    int pos = 0;
    while ((pos = s.find(old_val, pos)) != s.npos)
    {
        // 如果前一个是空格或者标点 并且 后一个是空格或者标点或者结束符（说明该old_val独立）
        if ((ispunct(s[pos - 1]) || s[pos - 1] == ' ') && (ispunct(s[pos + old_val.length()]) || s[pos + old_val.length()] == ' ' || s[pos + old_val.length()] == '\0'))
        {
            s.erase(pos, old_val.length());
            s.insert(pos, new_val);
        }
        pos++;
    }
}

void chatAI(string &s)
{
    cout << s << endl;
    // 让句首句末有空格，方便统一操作
    s = ' ' + s;
    s = s + ' ';

    // 清理多余空格，保证每块空格只有一个空格
    int pos = s.find("  ");
    while (pos != s.npos)
    {
        s.erase(pos, 1);
        pos = s.find("  ");
    }

    pos = 0;
    // 把标点符号前的空格删去
    while ((pos = s.find(' ', pos)) != s.npos)
    {
        if (ispunct(s[pos + 1]))
        {
            s.erase(pos, 1);
        }
        pos++;
    }

    change(s, "?", "!");

    // 把所有I特殊化（无论是否独立）
    change(s, "I", "#-#");
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    // 还原I
    change(s, "#-#", "I");

    // 特殊情况（如can I如果直接执行时，会改成can you，导致执行下面的替换can you）
    independ_change(s, "can I", "#--#");
    independ_change(s, "can me", "#--#");
    independ_change(s, "could I", "#---#");
    independ_change(s, "could me", "#---#");

    independ_change(s, "I", "you");
    independ_change(s, "me", "you");

    // 替换加上x是为了防止如（can you you错改成 I I can 的情况）
    independ_change(s, "could you", "I couldx");
    independ_change(s, "can you", "I canx");
    independ_change(s, "canx", "can");
    independ_change(s, "couldx", "could");

    independ_change(s, "#--#", "can you");
    independ_change(s, "#---#", "could you");

    // 删去句首空格
    while (s.find(' ') == 0)
    {
        s.erase(0, 1);
    }
    // 删去句末空格
    while (s.rfind(' ') == s.length() - 1)
    {
        if (s.length())
        {
            s.erase(s.length() - 1, 1);
        }
        else
        {
            break;
        }
    }
    cout << "AI: " << s;
}

int main()
{
    int n;
    cin >> n;
    cin.get();
    for (int i = 0; i < n; i++)
    {
        getline(cin, input[i]);
    }
    for (int i = 0; i < n; i++)
    {
        chatAI(input[i]);
        if (i != n - 1)
        {
            cout << endl;
        }
    }
    return 0;
}